from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtCore import Qt
import logo_rc

class LoadingProgress(QtWidgets.QDialog):
    def __init__(self, parent=None):
        super(LoadingProgress, self).__init__(parent)
        vbox = QtWidgets.QVBoxLayout(self)
        self.movie_laber = QtWidgets.QLabel()
        self.movie = QtGui.QMovie(":/rcc/Loading.gif")
        self.movie_laber.setMovie(self.movie)
        self.progress_laber = QtWidgets.QLabel()
        # 填满窗口
        self.movie_laber.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        vbox.addWidget(self.movie_laber)
        vbox.addWidget(self.progress_laber)
        self.setLayout(vbox)
        self.setAttribute(Qt.WA_TranslucentBackground)
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | Qt.Tool)
        # 透明度
        # self.setWindowOpacity(1)

    def start(self):
        self.progress_laber.setText("正在查询，请稍后...")
        # 居中
        self.progress_laber.setAlignment(Qt.AlignCenter)
        self.movie.start()
        self.show()

    def stop(self):
        self.movie.stop()
        self.close()
